//
//  LPSecretaryPrejectTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by 刘应平 on 2017/8/28.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPSecretaryPrejectTableViewCell.h"

@interface LPSecretaryPrejectTableViewCell ()
/**  图片  */
@property (strong, nonatomic) UIImageView  *prejectImageView;
/**  标题  */
@property (strong, nonatomic) UILabel  *headLine;
/**  详情  */
@property (strong, nonatomic) UILabel  *content;
/**  组织  */
@property (strong, nonatomic) UILabel  *orgLabel;


@end
@implementation LPSecretaryPrejectTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
    }
    return self;
}

- (void)layoutUI{
    [self addSubview:self.prejectImageView];
    [self addSubview:self.headLine];
    [self addSubview:self.content];
    [self addSubview:self.orgLabel];
    
    
    self.prejectImageView.sd_layout
    .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self,12 * [UIScreen zj_screenWScale])
    .heightIs(90 * [UIScreen zj_screenHScale])
    .widthIs(130 * [UIScreen zj_screenWScale]);
    
    self.headLine.sd_layout
    .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self.prejectImageView,10 * [UIScreen zj_screenWScale])
    .heightIs(12 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 162 * [UIScreen zj_screenWScale]);

    self.orgLabel.sd_layout
    .bottomEqualToView(self.prejectImageView)
    .leftEqualToView(self.headLine)
    .heightIs(12 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 162 * [UIScreen zj_screenWScale]);
    
    self.content.sd_layout
    .topSpaceToView(self.headLine,8 * [UIScreen zj_screenHScale])
    .leftEqualToView(self.headLine)
    .heightIs(50 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 162 * [UIScreen zj_screenWScale]);
   
    
    TenGrayShadowView *under = [TenGrayShadowView new];
    under.backgroundColor = [UIColor themeGrayColor];
    [self addSubview:under];
    under.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(10 * [UIScreen zj_screenHScale]);

}

- (void)setModel:(LPSecretaryPrejectModel *)model{
    _model = model;
    NSString *imageString = [model.IMG_JSON objectForKey:@"filePath"];
     [self.prejectImageView sd_setImageWithURL:CREATEURL(imageString) placeholderImage:PlaceholderImage];
    self.headLine.text = model.NAME;
    self.orgLabel.text = model.SPONSOR;
    self.content.attributedText = [UILabel setSpaceForLineWithText:model.SUMMARY lineSpace:4 * [UIScreen zj_screenHScale]];
    if (model.CONTENTHEIGHT < 50 * [UIScreen zj_screenHScale]) {
        self.content.sd_layout.heightIs(model.CONTENTHEIGHT);
        [self.content updateLayout];
    }
}

#pragma mark - getter
- (UIImageView *)prejectImageView{
    if (!_prejectImageView) {
        _prejectImageView = [UIImageView new];
        _prejectImageView.contentMode = UIViewContentModeScaleAspectFill;
        _prejectImageView.clipsToBounds = YES;
    }
    return _prejectImageView;
}

- (UILabel *)headLine{
    if (!_headLine) {
        _headLine = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = LYPFONT(16);
            label;
        });
    }
    return _headLine;
}



- (UILabel *)content{
    if (!_content) {
        _content = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = LYPFONT(15);
            label.numberOfLines = 0;
            label;
        });
    }
    return _content;
}


- (UILabel *)orgLabel{
    if (!_orgLabel) {
        _orgLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = LYPFONT(14);
            label;
        });
    }
    return _orgLabel;
}



@end
